import { Module } from '@nestjs/common';
import { ConfigModule as NestConfigModule } from '@nestjs/config';
import { DatabaseModule } from './database/database.module';
import { RedisModule } from './redis/redis.module';
import configuration from './configuration';

@Module({
  imports: [
    NestConfigModule.forRoot({
      isGlobal: true,
      load: [configuration],
      envFilePath: '.env',
    }),
    DatabaseModule,
    RedisModule,
  ],
  exports: [DatabaseModule, RedisModule],
})
export class ConfigModule {
  static forRoot() {
    return {
      module: ConfigModule,
      global: true,
      load: [configuration],
    };
  }
}
